package com.nightpiter.view.dialogs;

import java.util.Map;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nightpiter.R;
import com.nightpiter.model.objects.Station;

/**
 * StationSelectionItem class.
 * 
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */
public class StationSelectionItem extends LinearLayout {

	/**
	 * station to draw
	 */
	private Station station;

	/**
	 * icon in the row
	 */
	private StationIcon stationIcon;

	/**
	 * textView containing station name
	 */
	private TextView stationName;

	/**
	 * @param context
	 */
	public StationSelectionItem(Context context) {
		super(context);
	}

	/**
	 * @param context
	 * @param attrs
	 * @param inflateParams
	 */
	@SuppressWarnings("unchecked")
	public StationSelectionItem(Context context, AttributeSet attrs,
			Map inflateParams) {
		super(context, attrs, inflateParams);
	}

	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		init();
	}

	/**
	 * linking to layout views
	 */
	private void init() {
		this.stationIcon = (StationIcon) findViewById(R.id.station_icon);
		this.stationName = (TextView) findViewById(R.id.station_name);
	}

	/**
	 * @return the station
	 */
	public Station getStation() {
		return station;
	}

	/**
	 * @param station
	 *            the station to set
	 */
	public void setStation(Station station) {
		this.station = station;
		this.stationIcon.setStation(station);
		this.stationName.setText(station.getName());
	}

}
